package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.form.OrderDataForm;
import com.yxinsur.imc.business.form.OrderImgForm;
import com.yxinsur.imc.business.form.OrderSearchForm;
import com.yxinsur.imc.business.service.IImcOrderImgService;
import com.yxinsur.imc.business.service.IImcOrderService;
import com.yxinsur.imc.business.vo.OrderImgVo;
import com.yxinsur.imc.business.vo.OrderVo;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 保单影像件Controller
 * 
 * @author imc
 * @date 2021-03-29
 */
@Api(value="保单影像件模块接口服务",tags={"2.2.保单影像件模块接口服务"})
@RestController
@RequestMapping("/business/order/img")
public class ImcOrderImgController extends BaseController
{
    @Autowired
    private IImcOrderService imcOrderService;
    @Autowired
    private IImcOrderImgService imcOrderImgService;

    /**
     * 查询保单列表
     */
    @GetMapping("/list")
    @ApiOperation("保单影像件列表查询")
    public TableDataInfo list(OrderSearchForm searchForm)
    {
        startPage();
        List<OrderVo> list = imcOrderService.selectQueryOrderList(searchForm);
        return getDataTable(list);
    }

    /**
     * 导出保单影像件列表
     */
    @ApiOperation("保单影像件列表导出")
    @GetMapping("/export")
    public AjaxResult export(OrderSearchForm searchForm)
    {
        List<OrderVo> list = imcOrderService.selectQueryOrderList(searchForm);
        ExcelUtil<OrderVo> util = new ExcelUtil<OrderVo>(OrderVo.class);
        return util.exportExcel(list, "保单影像件列表数据");
    }
    /**
     * 查询保单影像件列表
     */
    @GetMapping("/{id}")
    @ApiOperation("查询指定保单的影像件列表")
    public TableDataInfo imglist(@PathVariable("id") String id)
    {
        startPage();
        List<OrderImgVo> list = imcOrderImgService.selectOrderImgListByOrderId(id);
        return getDataTable(list);
    }
    /**
     * 导出保单影像件列表
     */
    @GetMapping("/{id}/export")
    @ApiOperation("查询指定保单的影像件导出数据")
    public AjaxResult imgListExport(@PathVariable("id") String id)
    {
        List<OrderImgVo> list = imcOrderImgService.selectOrderImgListByOrderId(id);
        ExcelUtil<OrderImgVo> util = new ExcelUtil<OrderImgVo>(OrderImgVo.class);
        return util.exportExcel(list, "保单影像件列表数据");
    }

    @ApiOperation("追加新增影像件")
    @PostMapping
    public AjaxResult add(@RequestBody OrderImgForm imgForm)
    {
        return toAjax(imcOrderImgService.insertImcOrderImg(imgForm));
    }
}
